/*
 * @Description: Description
 * @Autor: Chen
 * @Date: 2021-04-30 14:05:35
 * @LastEditors: snzo.chen
 * @LastEditTime: 2021-09-27 16:52:48
 */
import { Injectable } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http';
import { AnyJson } from './data-types/common.type';
import { Observable, map } from 'rxjs';
import { ServicesModule } from './services.module';

@Injectable({
  providedIn: ServicesModule,
})
export class VideoService {
  constructor(private http: HttpClient) {}

  getVideoList(params: AnyJson, body: AnyJson): Observable<AnyJson> {
    return this.http
      .post('/video/videoMsgSearch', body, { params })
      .pipe(map((res) => res as AnyJson));
  }

  getVideo(params: AnyJson): Observable<AnyJson> {
    return this.http
      .get('/video/videoMsgSearchOne', { params })
      .pipe(map((res) => res as AnyJson));
  }

  addVideo(params: AnyJson): Observable<AnyJson> {
    return this.http
      .post('/video/insertVideo', params)
      .pipe(map((res) => res as AnyJson));
  }

  updateVideo(params: AnyJson): Observable<AnyJson> {
    return this.http
      .post('/video/videoMsgUpdate', params)
      .pipe(map((res) => res as AnyJson));
  }

  delVideo(params: AnyJson, body: AnyJson): Observable<AnyJson> {
    return this.http
      .post('/video/videoMsgDel', body, { params })
      .pipe(map((res) => res as AnyJson));
  }
  clearSort(params: AnyJson): Observable<AnyJson> {
    return this.http
      .get('/video/clearVideoSort', { params })
      .pipe(map((res) => res as AnyJson));
  }
}
